<template>
  <div id="resourceManagement">
    <div id="tabelTitle">
      退费列表
    </div>
    <div id="table">
      <avue-crud
        v-model="form"
        :search.sync="searchForm"
        :page.sync="page"
        :data="tableData"
        :table-loading="tableLoading"
        :option="tableOption"
        @on-load="getList"
        @search-change="searchChange"
        @refresh-change="refreshChange"
        @size-change="sizeChange"
        @current-change="currentChange"
        @row-update="handleUpdate"
        @row-save="handleSave"
        @row-del="rowDel"
      >
        <template slot-scope="{disabled,size}" slot="stuNameSearch">
          <div class="inputStyle">
            <el-input placeholder="请输入姓名或手机号" :disabled="disabled" :size="size" style="width:50%; "
                      v-model="searchForm.keyWord"></el-input>
          </div>
        </template>

      </avue-crud>
    </div>
  </div>
</template>

<script>
import tableMixins from "@/mixins/tableMixin.vue"

export default {
  name: "refundList",
  mixins: [tableMixins],
  data() {
    return {
      isSubmit:false,
      form: {},
      data: [],
      //访问接口前缀
      url: "yuanjiu.testnew/tn-fee-refund-inf",
      searchForm: {},
      // 表格参数
      tableOption: {
        labelWidth:200,
        searchSpan:6,
        border: true,
        index: false,
        indexLabel: '序号',
        indexWidth: 50,
        stripe: true,
        align: 'center',
        searchMenuSpan:10,
        // searchLabelWidth: 100,
        calcHeight: 300,
        dialogWidth: 900,
        menuWidth: 200,
        menu: false,
        menuAlign: 'center',
        refreshBtn: false,
        columnBtn: false,
        searchShowBtn: false,
        selection: true,
        rowKey: "id",
        viewBtn: false,
        addBtn: true,
        emptyBtn: true,
        editBtn: false,
        delBtn: false,
        emptyBtnText: "重置",
        editBtnText: "修改",
        maxHeight: 645000,
        searchSize: "medium",
        column: [
          {
            prop: 'stuName',
            label: '姓名',
            search: true,
            searchLabelWidth: '50',
            addDisabled: true,
          },
          {
            prop: 'phoneNum',
            label: '手机号',
            change: ({value}) => {
              if (value.length == 11) {
                this.$httpService.get('/yuanjiu.testnew/tn-fee-refund-inf/getStuInfoByPhoneNum?phoneNum=' + value).then(res => {
                  this.form = res
                  this.isSubmit =true
                })
              }
            },
          },
          {
            prop: 'productId',
            label: '培训类别',
            type: "select",
            dicUrl: '/yuanjiu.testnew/tn-product/listTnProduct',
            dicMethod: 'post',
            search: true,
            searchLabelWidth: '80',
            props: {
              label: 'productName',
              value: 'productId',
              res: 'result'
            },
            editDisabled: true,
            addDisplay: false,
          },
          {
            label: "班级名称",
            prop: "classId",
            search: true,
            searchLabelWidth: '80',
            type: "select",
            dicUrl: '/yuanjiu.testnew/tn-class/listTnClass',
            dicMethod: 'post',
            props: {
              label: 'className',
              value: 'classId',
              res: 'result'
            },
            editDisabled: true, addDisabled: true,
          },
          {
            prop: 'belongUserId',
            label: '咨询师',
            addDisplay: false,
          }
          ,
          {
            prop: 'refundAmt',
            label: '应退金额',
          },
          {
            prop: 'tuition',
            label: '已缴学费',
            hide: true,
            addDisplay: false,
          },
          {
            prop: 'refundAmt',
            label: '退款方式',
            hide: true,
          },
          {
            prop: 'refundTime',
            label: '退款时间',
            type: "date",
            format:'yyyy-MM-dd',
            valueFormat:'yyyy-MM-dd',
            editDisabled: true, addDisplay: false,
          }, {
            prop: 'refundAcctNum',
            label: '退款账号',
            hide:true,
            editDisplay: false,
          },
        ]
      },
      listUrl: 'pageTnFeeRefundInf',
      delUrl: "deleteList",
      delIdList: [],

    }
  },
  methods:{
    handleSave: function (row, done, loading) {
      if(this.isSubmit){
        this.$httpService.post("/" + this.url + "/"+this.addUrl, row).then(res => {
          this.$message.success('新增成功');
          this.getList();
          done();
          loading();
        }).catch(res=>{
          loading();
        })
      }
      else {
        this.$message.error('请输入正确手机号码查询');
        loading();
      }

    },
  }

}
</script>

<style scoped>
.inputStyle{
  width: 600px;
}
@media only screen and (max-width: 1600px){
  .inputStyle{
    width: 530px;
  }
}
@media only screen and (max-width: 1500px){
  .inputStyle{
    width: 430px;
  }
}
@media only screen and (max-width: 1366px){
  .inputStyle{
    width: 330px;
  }
}
@media only screen and (max-width: 900px){
  .inputStyle{
    width: 600px;
  }
}

</style>
